package com.ziyia.viewmodel;

import android.util.Log;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;

public class MyObserver implements LifecycleObserver {

    private Lifecycle lifecycle;

    public MyObserver() {
    }

    public MyObserver(Lifecycle lifecycle) {
        this.lifecycle = lifecycle;
    }

    private static final String TAG = MyObserver.class.getName();

    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    public void activityStart() {
        Log.d(TAG, "activityStart: ");
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    public void activityStop() {
        Log.d(TAG, "activityStop: ");
    }

    public void getActivityStatus() {
        Log.d(TAG, "getActivityStatus: " + lifecycle.getCurrentState().name());
    }
}
